#!/usr/bin/python
# -*- coding: UTF-8 -*-
import json,nconfig
def Read(i,x):
    count = len(open(nconfig.R_file[i],'rU').readlines())
    #print(count);
    temp=nconfig.O_List[i]
    cc=len(temp[0])
    #print(cc)
    y=temp*x
    #print(y)
    fo= open(nconfig.R_file[i],"r")
    #print(count)
    for index in range(count):
        str_t=fo.next().strip('\n');
        if(index==0):
            nconfig.head['version'] = str_t;
        else:
            h=index/cc
            u=index%cc
            if(i==0):
                if(u==1):
                    y[h]['plantName']=str_t
                elif(u==2):
                    y[h]['shopName']=str_t
                elif(u==3):
                    y[h]['conveyorName']=str_t
                elif(u==4):
                    y[h]['shift']=str_t
                elif(u==5):
                    y[h]['shiftDay']=str_t
                elif(u==6):
                    y[h]['goalProduction']=str_t
                elif(u==7):
                    y[h]['actualProduction']=str_t
                else:
                    y[h-1]['downTime']=str_t

            elif (i==1):
                pass
            elif(i==2):
                pass
            elif(i==3):
                pass
            elif(i==4):
                pass

        nconfig.send_data['head']=nconfig.head
        nconfig.send_data['body']=y
    fo.close();
    return nconfig.send_data
def Write():

    return;
